package com.eveinfo.api.accessors;

import java.io.IOException;
import java.util.ArrayList;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import com.eveinfo.EveInfo;
import com.eveinfo.api.ApiAuthorization;
import com.eveinfo.api.ApiException;
import com.eveinfo.api.NoCacheFoundExecption;
import com.eveinfo.api.character.skillqueue.ApiSkillQueue;
import com.eveinfo.api.character.skillqueue.SkillQueueParser;
import com.eveinfo.api.character.skillqueue.SkillQueueResponse;
import com.eveinfo.tools.EveInfoPreferences;
import com.eveinfo.tools.Tools;

public class SkillQueue {

	private ArrayList<ApiSkillQueue> list;

	public SkillQueue(int userID, long characterID, String apiKey) throws IOException, SAXException,
			ParserConfigurationException, ApiException, NoCacheFoundExecption {
		SkillQueueParser parser = SkillQueueParser.getInstance();
		final EveInfoPreferences preferences = EveInfo.getPreferences();
		if (preferences.isCacheOnly()) {
			parser.setCacheOnly(true);
			preferences.setEnableCache(true);
		} else {
			parser.setCacheOnly(false);
		}
		if (preferences.isEnableCache()) {
			Tools.setCacheEnable(parser);
		} else {
			Tools.setCacheDisable(parser);
		}
		SkillQueueResponse response = parser.getSkillsInQueue(new ApiAuthorization(userID, characterID, apiKey));
		list = new ArrayList<ApiSkillQueue>(response.getSkillQueue());
	}

	public ArrayList<ApiSkillQueue> getSkillQueue(){
		return list;
	}
	
}
